package com.inhgroup.flashcards.data;

import java.util.List;

/**
 * A collection of Cards that also stores the names of the languages on each side of the Cards.
 * 
 * @author Branden Ogata
 *
 */

public class CardList
{
  /**
   * The title of this CardList.
   * 
   */
  private String title;
  
  /**
   * The cards in this CardList.
   * 
   */
  private List<Card> cards;
  
  /**
   * The name of the language on the front of the cards.
   * 
   */
  private String frontLanguage;

  /**
   * The name of the language on the back of the cards.
   * 
   */
  private String backLanguage;
  
  /**
   * The index of the most recent Card displayed in this CardList.
   * 
   */
  private int lastCard;
  
  /**
   * Creates a new CardList.
   * 
   * @param title The String containing the title of the new CardList.
   * @param cards The List<Card> containing the cards to store in the new CardList.
   * @param frontLanguage The String containing the name of the language on the front of the cards.
   * @param backLanguage The String containing the name of the language on the back of the cards.
   * 
   */
  
  public CardList(String title, List<Card> cards, String frontLanguage, String backLanguage)
  {
    this.title = title;
    this.cards = cards;
    this.frontLanguage = frontLanguage;
    this.backLanguage = backLanguage;
    this.lastCard = 0;
  }

  /**
   * Returns the title of this CardList.
   * 
   * @return A String containing the title of this CardList.
   * 
   */
  
  public String getTitle()
  {
    return this.title;
  }
  
  /**
   * Returns the language shown on the front of the cards in this CardList.
   * 
   * @return A String containing the name of the language on the front of the cards.
   * 
   */
  
  public String getFrontLanguage()
  {
    return this.frontLanguage;
  }

  /**
   * Returns the language shown on the back of the cards in this CardList.
   * 
   * @return A String containing the name of the language on the back of the cards.
   * 
   */
  
  public String getBackLanguage()
  {
    return this.backLanguage;
  }
  
  /**
   * Returns the element in this CardList at the given index.
   * 
   * @param index The int equal to the index at which to get a Card.
   * 
   * @return The Card at the specified index.
   * 
   */
  
  public Card getCard(int index)
  {
    this.lastCard = index;
    return this.cards.get(index);
  }
  
  /**
   * Returns the number of cards in this CardList.
   * 
   * @return An int equal to the number of cards in this CardList.
   * 
   */
  
  public int getSize()
  {
    return this.cards.size();
  }
  
  /**
   * Returns the index of the most recent card displayed in this CardList.
   * 
   * @return An int equal to the index of the last Card provided through getCard.
   *         If getCard has not yet been called, returns 0.
   *         
   */
  
  public int lastCardIndex()
  {
    return this.lastCard;
  }
}